package com.auqaoasis.model.table.tableFile;

import com.auqaoasis.model.page.Page;
import com.auqaoasis.model.page.PageID;
import com.auqaoasis.model.row.Row;
import com.auqaoasis.model.table.TableDesc;
import com.auqaoasis.operator.ITableFileIterator;

import java.io.IOException;

/**
 * @Author Auqaoasis
 * @Date 2022/4/1 - 21:50
 * @Description:
 */
public interface TableFile {
    /**
     * 获取该表的结构
     */
    TableDesc getTableDesc();

    /**
     * 读取一页数据
     *
     * @param pageID pageID
     * @return page
     */
    Page readPageFromDisk(PageID pageID) throws IOException;

    /**
     * 写数据至磁盘
     */
    void writePageToDisk(Page page);

    /**
     * 返回文件的唯一id
     * 取文件绝对路径散列值
     */
    int getTableId();

    /**
     * 文件中已存在的page数量
     */
    int getExistPageCount();

    void insertRow(Row row) throws IOException;

    void deleteRow(Row row);

    ITableFileIterator getIterator();
}
